package com.xiaoshuidi.cloud.module.contract.enums.bill;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

/**
 * 账单支付状态枚举类
 */
@Getter
@AllArgsConstructor
public enum OrderPayStatusEnum {
    UNPAID("unpaid", "待支付"),
    PAID("payment", "已支付"),
    PROCESS("process", "处理中"),
    PART("part", "部分支付"),
    CANCEL("cancel", "取消"),
    // 换房冻结 临时状态
    FREEZE("freeze", "冻结"),
    ;
    private final String code;
    private final String msg;

    public static String getMsgByCode(String code) {
        if (StrUtil.isEmpty(code)) {
            return "";
        }
        Optional<String> first = Arrays.stream(OrderPayStatusEnum.values()).filter(s -> s.getCode().equals(code)).map(s -> s.getMsg()).findFirst();
        if (first.isPresent()) {
            return first.get();
        }
        return "";
    }
}
